<template>
    <i class="file-icon" :class="iconSrc"></i>
</template>

<script>
  export default {
    name: "CheckIcon",
    data() {
      return {
        iconSrc: 'icon-1-1'
      }
    }, props: {
      fileData: {
        type: Object,
        default: function () {
          return {isHome:true}
        }
      }
    }, created() {
      this.checkFileType()
    }, watch: {


      fileData : {
        handler:function() {
          this.checkFileType()
        },
        deep: true
      }
    },
    methods: {
      checkFileType: function () {
       if(this.fileData.fileType === 2){
         return this.iconSrc = 'icon-4-4'
       }
        if (this.fileData.isHome) {
          return this.iconSrc = 'icon-1-1'
        }
        const fileName = this.fileData.name || this.fileData.displayName
        if(!fileName)  return this.iconSrc = 'icon-1-1'
        const nameArr = fileName.split('.')
        if (this.fileData.fileType === 1) {
          if (this.fileData.property === 0) {
            this.iconSrc = 'icon-1-1'
          } else {
            this.iconSrc = 'icon-1-2'
          }
        } else {
          this.iconSrc = this.publicFun.checkIcon(nameArr[nameArr.length - 1])
        }
      }
    }
  }
</script>

<style scoped>

    .file-icon{
        height: 25px;
        width: 25px;
        background-image: url("/file_icon/file_icon_list.png") ;
        display: inline-block;
        vertical-align: middle;
        background-size: 140px;
    }

    .icon-1-1{
        background-position: -5px -7px;
    }

    .icon-1-2{
        background-position: -40px -7px;
    }

    .icon-1-3{
        background-position: -75px -7px;
    }

    .icon-1-4{
        background-position: -110px -7px;
    }

    .icon-2-1{
        background-position: -5px -38px;
    }

    .icon-2-2{
        background-position: -40px -38px;
    }

    .icon-2-3{
        background-position: -75px -38px;
    }

    .icon-2-4{
        background-position: -110px -38px;
    }

    .icon-3-1{
        background-position: -5px -69px;
    }

    .icon-3-2{
        background-position: -40px -69px;
    }

    .icon-3-3{
        background-position: -75px -69px;
    }

    .icon-3-4{
        background-position: -110px -69px;
    }


    .icon-4-1{
        background-position: -5px -100px;
    }

    .icon-4-2{
        background-position: -40px -100px;
    }

    .icon-4-3{
        background-position: -75px -100px;
    }

    .icon-4-4{
        background-position: -110px -100px;
    }

    .icon-5-1{
        background-position: -5px -131px;
    }

    .icon-5-2{
        background-position: -40px -131px;
    }

    .icon-5-3{
        background-position: -75px -131px;
    }

    .icon-5-4{
        background-position: -110px -131px;
    }

    .icon-6-1{
        background-position: -5px -162px;
    }

    .icon-6-2{
        background-position: -40px -162px;
    }

    .icon-6-3{
        background-position: -75px -162px;
    }

    .icon-6-4{
        background-position: -110px -162px;
    }

    .icon-7-1{
        background-position: -5px -193px;
    }

    .icon-7-2{
        background-position: -40px -193px;
    }

    .icon-7-3{
        background-position: -75px -193px;
    }

    .icon-7-4{
        background-position: -110px -193px;
    }

</style>
